package com.bd.rj.frontstage.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bd.rj.common.entity.Interview;
import com.bd.rj.frontstage.service.IInterviewService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

@RestController
public class InterviewController {

    @Resource
    private IInterviewService  interviewService;

    /**
     * @dews 投递简历
     * @author yxh
     * @date  2025-1-06
     */
    @PostMapping("/insertview")
    public Map<String,Object> insertInterview(Interview interview) {
        Map<String,Object> map = new HashMap<>();
         interviewService.save(interview);
         map.put("code", 200);
         map.put("msg", "投递成功");
         return map;
    }

    /**
     *
     * @dews 查询投递简历
     * @author WBW
     * @param uid 用户id
     * @param status 简历状态
     * @return
     */
    @GetMapping("/getview")
    public Map<String,Object> getInterview(Long uid , Integer status) {
        Map<String,Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "查询成功");
        map.put("data", interviewService.getInterviewById(uid,status));
        return map;
    }

    /**
     * @dews 查询投递简历的企业名称
     * @param uid 用户id
     * @return
     */
    @GetMapping("/getEname")
    public Map<String,Object> getEname(Long uid) {
        Map<String,Object> map = new HashMap<>();
        map.put("msg", "success");
        map.put("code", 200);
        map.put("data", interviewService.getEnameByUid(uid).stream().distinct().collect(Collectors.toList()));
        return map;
    }
    /**
     *
     * @dews 查询投递简历
     * @author WBW
     * @param ename 企业名称
     * @return
     */
    @GetMapping("/getviewEnameId")
    public Map<String,Object> getviewEnameId( String ename) {
        Map<String,Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "查询成功");
        map.put("data", interviewService.getviewByEname(ename));
        return map;
    }
}
